Skip to content

Add FW loiter size and orientation control #24625

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open

Conversation

ryanjAA
Copy link
Contributor

@ryanjAA ryanjAA commented Mar 27, 2025

Fixes: #24612

Params 3 and 4 handling are missing. This adds it in.

Param 3 now will respond to a loiter size and param 4 to 0/1 for CW/CCW.

Also, on alt only changes if you omit param3/4 it explicitly does what you have set as your default (rather than last done which is how it is now) to ensure you get the default unless the param is passed.

https://logs.px4.io/plot_app?log=61232f4d-fa71-4965-bd37-0be6c4740bb8
(Main from today)

https://discord.com/channels/1022170275984457759/1022186266957201480/1224558850179469414
https://discord.com/channels/1022170275984457759/1022186266957201480/1354505832426901546

Params 3 and 4 handling are missing. This adds it in.


Param 3 now will respond to a loiter size and param 4 to 0/1 for CW/CCW. 

Also, on alt only changes if you omit param3/4 it explicitly does what you have set as your default (rather than last done which is how it is now) to ensure you get the default unless the param is passed.
@ryanjAA
Copy link
Contributor Author

ryanjAA commented Mar 27, 2025

@sfuhrer

Also, this allows QGC to expose loiter size and direction control

Copy link
Contributor

@sfuhrer sfuhrer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for your contribution and sorry for the slow response. This looks largely good and follows the mavlink standard, I only have some small remarks.

@@ -392,7 +410,7 @@ void Navigator::run()
rep->current.loiter_pattern = position_setpoint_s::LOITER_TYPE_ORBIT;
}

rep->current.loiter_direction_counter_clockwise = curr->current.loiter_direction_counter_clockwise;
rep->current.loiter_direction_counter_clockwise = (PX4_ISFINITE(cmd.param4) ? (cmd.param4 >= 1.0f) : false);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we really need this separate handling? In the only_alt_change_requested case we, as the name says, want to keep everything beside the altitude as it was set before, no?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added this so when a 'change-altitude-only' command is sent (i.e. param3 and param4 omitted), we explicitly apply the vehicle’s default loiter radius and direction, exactly the behavior people expect today. Without this, the vehicle would continue using the previous radius/direction settings, which can be surprising.

Also, this makes the behavior match the MAVLink spec’s intent that omitted parameters revert to defaults.

That said, I don't actually care but I do think it's the right thing.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ryanjAA I still challenge that it's expected that if you send a "change altitude" through QGC the loiter direction changes (see screen-recording).
Could QGC send a full GoTo setpoint again? Probably, but it's currently not doing it, thus this change changes the current behavior.

Screencast.from.30-04-25.17.48.25.webm

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, this makes the behavior match the MAVLink spec’s intent that omitted parameters revert to defaults.

But then the lat/long fields should also not being assumed but reset to e.g. the current vehicle position. Currently there it keeps the lat/long from the previous setpoint.

ryanjAA and others added 3 commits April 29, 2025 19:08
Co-authored-by: Silvan Fuhrer <silvan@auterion.com>
Co-authored-by: Silvan Fuhrer <silvan@auterion.com>
@sfuhrer
Copy link
Contributor

sfuhrer commented Apr 30, 2025

And alternative is to use https://mavlink.io/en/messages/common.html#MAV_CMD_DO_ORBIT. We already have support on the PX4 side for it, incl. direction change.
@ryanjAA how do you intend to use this change? Will you change QGC along it or how do you send the reposition?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Loiter radius and Direction not working for FW via MAV_CMD_DO_REPOSITION
2 participants